package com.wawayaya.util;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;

import com.creative.accountsdk.AccountActivity;
import com.creative.accountsdk.teacher.ClassListActivity;
import com.creative.accountsdk.teacher.ClassStudentActivity;
import com.wawayaya.AppContext;
import com.wawayaya.parentteacher.ui.SelectBookActivity;
import com.wawayaya.service.DownloadService;
import com.wawayaya.parentteacher.ui.TeacherParentMainActivity;
import com.wawayaya.ui.MainActivity;
import com.wawayaya.ui.SettingActivity;

/**
 * 界面帮助类
 * @des  用于所有的Ui Activity 、 Broadcast 跳转
 *
 * 
 */
public class UIHelper {

    /**
     * 显示登录界面
     * 
     * @param context
     */
    public static void showLoginActivity(Context context) {
       // Intent intent = new Intent(context, LoginActivity.class);
      //  context.startActivity(intent);
    }

    /**
     * 显示首页 mainSettingActivity
     *
     * @param context
     */
    public static void showMainActivity(Context context){
        Intent intent = new Intent(context,MainActivity.class);
        context.startActivity(intent);
    }

    /**
     * 发送App异常崩溃报告
     *
     * @param context
     * @param
     */
    public static void sendAppCrashReport(final Context context) {

        DialogHelp.getConfirmDialog(context, "程序发生异常", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                // 退出
                System.exit(-1);
            }
        }).show();
    }

    /**
     * 打开系统中的浏览器
     * @param context
     * @param url
     */
    public static void openSysBrowser(Context context, String url) {
        try {
            Uri uri = Uri.parse(url);
            Intent it = new Intent(Intent.ACTION_VIEW, uri);
            context.startActivity(it);
        } catch (Exception e) {
            e.printStackTrace();
            AppContext.showToastShort("无法浏览此网页");
        }
    }

    /**
     * 显示一账通界面
     *
     * @param context
     */
    public static void showAccountActivity(Context context,String  flag, int requestCode) {
         Intent intent = new Intent(context, AccountActivity.class);
         intent.putExtra("flag", flag);
         //context.startActivity(intent);
        ((Activity)context).startActivityForResult(intent, requestCode);
    }


    /**
     * 教师 - 班级列表
     *
     * @param context
     */
    public static void showTeacherClassActivity(Context context) {
        Intent intent = new Intent(context, ClassListActivity.class);
        context.startActivity(intent);
    }

    /**
     * 显示设置界面
     *
     * @param context
     */
    public static void showSettingActivity(Context context) {
        Intent intent = new Intent(context, SettingActivity.class);
        context.startActivity(intent);
    }

    /**
     * 显示设置界面
     *
     * @param context
     */
    public static void showStudentActivity(Context context) {
        Intent intent = new Intent(context, ClassStudentActivity.class);
        context.startActivity(intent);
    }

    /**
     * 显示家长或者教师中心首页
     *
     * @param context
     */
    public static void showTeacherParentActivity(Context context) {
        Intent intent = new Intent(context, TeacherParentMainActivity.class);
        context.startActivity(intent);
    }

    /**
     * 显示家长或者教师中心选书页
     *
     * @param context
     */
    public static void showTpSelectBookActivity(Context context) {
        Intent intent = new Intent(context, SelectBookActivity.class);
        context.startActivity(intent);
    }




    /**
     * 启动下载服务
     * @param context
     * @param target
     */
    private   void  toDownloadService(Context context,int target){
        TLog.log(".......to Download service......");
        Intent  intent =new Intent();
            intent.setClass(context, DownloadService.class);
        intent.setFlags(target);
        context.startService(intent);
    }
}
